import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: HP
 * Date: 2023 -04 -05
 * Time: 15:56
 */
public class MyQueue {
    private int[] element;
    private int size;
    private final int Cap=8;//初始空间大小
    public MyQueue(){
        element=new int[Cap];
    }
    public boolean empty(){
        return size==0;
    }
    public int getSize(){
        return size;
    }
    private boolean isFull(){
        return size==element.length;
    }
    public void enQueue(int val){
        if(isFull()){
            element= Arrays.copyOf(element,element.length*2);
        }
        element[size++]=val;
    }
    public int deQueue(){
        if(empty()){
            throw new RuntimeException("element is empty!");
        }
        int val=element[0];
        for(int i=0;i+1<size;i++){
            element[i]= element[i+1];
        }
        size--;
        return val;
    }
    public static void main(String[] args) {
        MyQueue mq=new MyQueue();
        mq.enQueue(1);
        mq.enQueue(2);
        mq.enQueue(3);
        System.out.println(mq.deQueue());
        mq.enQueue(4);
        mq.enQueue(5);
        mq.enQueue(6);
        System.out.println(mq.deQueue());
        mq.enQueue(1);
        mq.enQueue(1);
        mq.enQueue(4);
        mq.enQueue(5);
        mq.enQueue(6);
        while(!mq.empty()){
            System.out.print(mq.deQueue()+" ");
        }
        System.out.println();
    }
}
